<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:variable name="cssPath" select="simorg/paths/css" />
	<xsl:variable name="imagePath" select="/simorg/paths/images" />
	<xsl:variable name="rootUrl" select="simorg/paths/rootUrl" />
	
	<xsl:template match="/">
		<html xmlns:html="http://www.w3.org/TR/xhtml1/strict" lang="en-US" >
			<head>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
				<link type="text/css" href="{$cssPath}/custom-theme/jquery-ui-1.8.9.custom.css" rel="Stylesheet"/>
				<link type="text/css" href="{$cssPath}main.css" rel="Stylesheet"/>
				<script type="text/javascript" src="http://localhost:8091/simorg/js/jquery-1.4.4.min.js"/>
				<script type="text/javascript" src="http://localhost:8091/simorg/js/jquery-ui-1.8.9.custom.min.js"></script>
				
				<script type="text/javascript">
				
					$(document).ready(function(){
						$(".button").button();
						$('.striped tr:even').addClass('alt');
  						$(".userRemoveLink").button({
            				icons: {
                				primary: "ui-icon-circle-close"
            				},
           					text: false
           				});
           				$(".userRemoveLink").click(function(e) {
    						e.preventDefault();
    						var targetUrl = $(this).attr("href");
							$("#dialog-confirm").dialog({
	     						 buttons : {
							        "Delete user" : function() {
							          window.location.href = targetUrl;
							        },
							        Cancel : function() {
							          $(this).dialog("close");
							        }
							      }
						    });
							$("#dialog-confirm").dialog("open");
   						});
           				
           				$( "#dialog-confirm" ).dialog({
  							autoOpen: false,
							resizable: false,
							height:240,
							width:450,
							modal: true
						});
  					});
				</script>
				
				<title>SimOrg Users</title>
			</head>
			<body>
				<div class="ui-widget top_toolbar" style="font-size:smaller"><span style="float:left" >Simorg Administration Dashboard</span><a class="logoutLink" href="{$rootUrl}admin/logout">logout</a></div>
             	
				 <div id="primaryformdiv" class="ui-widget ui-widget-content ui-corner-all">
             		<h3 style="margin:0px;padding:.5em" class="ui-widget-header div-title">User List</h3>
             		<table class="striped" style="margin-top:1em;width:100%">
             			<tr>
             			<th>&#160;</th>
             			<th>Username</th>
             			<th>Last Name</th>
             			<th>First Name</th>
             			<th>Role</th>
             			
             			</tr>
             			<xsl:for-each select="simorg/users/user">
             			<tr>
             				<td style="text-align:center"><a class="userRemoveLink" href="{$rootUrl}user/delete/{@id}">Remove User</a></td>
             				<td style="text-align:center"><a href="{$rootUrl}user/view/{@id}"><xsl:value-of select="username"/></a></td>
             				<td style="text-align:center"><xsl:value-of select="lastName"/></td>
             				<td style="text-align:center"><xsl:value-of select="firstName"/></td>
             				<td style="text-align:center"><xsl:value-of select="role"/></td>
             				
             			</tr>
             			</xsl:for-each>
             		
             		</table>
             		<div class="toolbar">
             			<a class="button toolbar_button" href="{$rootUrl}course/list/">View All Courses</a>
             		</div>
             		<div id="dialog-confirm" title="Remove User?">
						<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This will remove the user permanently. Are you sure?</p>
				</div>
             	</div>
			</body>
		</html>
	</xsl:template>
	
</xsl:stylesheet>